package phone.qyg.com.qyg.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.List;

/**
 * 作者：lblbh on 2017/2/27 17:03
 * 邮箱：lanbuhan@163.com
 * 功能：TODO
 */
public class FramgmentAdapter extends FragmentStatePagerAdapter {


    private List<Fragment> mList;
    private String[] titles;


    public FramgmentAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setFramgmentList(List<Fragment> mList){
        this.mList = mList;
    }

    public void setPagetTitlePage(String[] titles){
        this.titles = titles;
    }
    @Override
    public Fragment getItem(int position) {
        return mList.get(position);
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if(position<titles.length){
            return titles[position];
        }
        return position + "";
    }


}